import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'doufeng_tacit_model.dart';

class InvitingToWidget extends StatefulWidget {
  // final TacitPush tacitPush;

  InvitingToWidget();

  @override
  State<InvitingToWidget> createState() => _InvitingToWidgetState();
}

class _InvitingToWidgetState extends State<InvitingToWidget> {
  @override
  void initState() {
    super.initState();
    context.read<DoufengTacitModel>().autoDismissFunc();
  }

  @override
  Widget build(BuildContext context) {
    return Consumer<DoufengTacitModel>(builder: (context, model, child) {
      return Container(
        padding: const EdgeInsets.symmetric(
          horizontal: 34,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const Row(
              children: [
                // AvatarImage(
                //   url: widget.tacitPush.userInfo.avatar,
                //   width: 52,
                //   height: 52,
                //   borderRadius: 26,

                //   placeholder: (context, url) => Image.asset(
                //     'assets/images/contact_avatar_default.png',
                //   ),
                //   errorWidget: (context, url, error) {
                //     return Image.asset(
                //       'assets/images/contact_avatar_default.png',
                //     );
                //   },
                // ),
                Text('AvatarImage'),
                SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Text(
                    "开启了默契测试，一起来测测默契值吧",
                    style: TextStyle(
                      fontSize: 13,
                      fontWeight: FontWeight.w500,
                      color: Colors.white,
                    ),
                  ),
                )
              ],
            ),
            const SizedBox(
              height: 37,
            ),
            Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                Expanded(
                  child: CupertinoButton(
                    onPressed: () {
                      // widget.onCancel();
                      // DoufengTacitModel.tacitResponse(context, false,
                      //     model.roomModel.channel!.channelId);
                      /// 关闭定时器
                      model.cancelTimer();
                      Navigator.pop(context);
                    },
                    minSize: 0,
                    padding: EdgeInsets.zero,
                    child: Container(
                      height: 42,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(21),
                        border: Border.all(
                          color: const Color(0xFF8F5CFF),
                          width: 1,
                        ),
                      ),
                      alignment: Alignment.center,
                      child: const Text(
                        "残忍拒绝",
                        style: TextStyle(
                          fontSize: 14,
                          fontWeight: FontWeight.w500,
                          color: Color(0xFF8F5CFF),
                        ),
                      ),
                    ),
                  ),
                ),
                const SizedBox(
                  width: 11,
                ),
                Expanded(
                  child: CupertinoButton(
                    onPressed: () {
                      // widget.onConfirm();
                      // DoufengTacitModel.tacitResponse(context, true,
                      //     model.roomModel.channel!.channelId);
                      model.cancelTimer();
                    },
                    minSize: 0,
                    padding: EdgeInsets.zero,
                    child: Container(
                      height: 42,
                      decoration: BoxDecoration(
                        gradient: const LinearGradient(
                            colors: [Color(0xFFEC6FA9), Color(0xFFEA3B7B)]),
                        borderRadius: BorderRadius.circular(21),
                      ),
                      alignment: Alignment.center,
                      child: const Text(
                        "愉快接受",
                        style: TextStyle(
                          fontSize: 14,
                          fontWeight: FontWeight.w500,
                          color: Colors.white,
                        ),
                      ),
                    ),
                  ),
                )
              ],
            ),
            const SizedBox(
              height: 11,
            ),
            Text(
              "${model.autoDismissSec}s 后自动接收",
              style: const TextStyle(
                fontSize: 13,
                fontWeight: FontWeight.w500,
                color: Colors.white,
              ),
            )
          ],
        ),
      );
    });
  }
}
